//
//  CRMyCell.m
//  NewAge
//
//  Created by dllo on 15/12/3.
//  Copyright © 2015年 ColorRevolution. All rights reserved.
//

#import "CRMyCell.h"

@implementation CRMyCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.myImageView = [[UIImageView alloc] init];
        //        self.myImageView.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:self.myImageView];
        
        self.myLabel = [[UILabel alloc] init];
        //        self.myLabel.backgroundColor = [UIColor greenColor];
        self.myLabel.font = [UIFont boldSystemFontOfSize:20];
        [self.contentView addSubview:self.myLabel];
        
        self.twoLabel = [[UILabel alloc] init];
        //        self.twoLabel.backgroundColor = [UIColor redColor];
        self.twoLabel.textColor = [UIColor grayColor];
        self.twoLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.twoLabel];
        
        self.threeLabel = [[UILabel alloc] init];
//                self.threeLabel.backgroundColor = [UIColor blueColor];
        self.threeLabel.textColor = [UIColor grayColor];
        self.threeLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.threeLabel];
        
//        self.fourLabel = [[UILabel alloc] init];
//        self.fourLabel.textColor = [UIColor grayColor];
//        self.fourLabel.font = [UIFont systemFontOfSize:15];
//        [self.contentView addSubview:self.fourLabel];
        
        //        self.timeImageView = [[UIImageView alloc] init];
        //        self.timeImageView.backgroundColor = [UIColor redColor];
        //        [self.threeLabel addSubview:self.timeImageView];
        
        self.playImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.playImageView];
        
        
        
        
        
        
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [self.myLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(10);
        make.right.equalTo(self.contentView.mas_right).with.offset(-10);
        make.top.equalTo(self.contentView.mas_top).with.offset(0);
        make.height.mas_equalTo(40 * HEIGHT / 667.0);
    }];
    
    [self.twoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(10);
        make.right.equalTo(self.contentView.mas_right).with.offset(-10);
        make.top.mas_equalTo(self.myLabel.mas_bottom);
        make.height.mas_equalTo(30 * HEIGHT / 667.0);
    }];
    [self.myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(10);
        make.right.equalTo(self.contentView.mas_right).with.offset(-10);
        make.top.equalTo(self.twoLabel.mas_bottom).with.offset(5);
        make.height.mas_equalTo(self.contentView.frame.size.height / 3 * 2);
    }];
    //    [self.timeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.left.equalTo(self.contentView.mas_left).with.offset(10);
    //        make.right.mas_equalTo(10);
    //        make.top.equalTo(self.myImageView.mas_bottom).with.offset(5);
    //        make.height.mas_equalTo(self.fourLabel);
    //    }];
    
    [self.threeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(10);
        make.right.equalTo(self.contentView.mas_right).with.offset(-10);
        make.top.equalTo(self.myImageView.mas_bottom).with.offset(2);
        make.height.mas_equalTo(45 * HEIGHT / 667.0);
//        make.width.equalTo(self.contentView.mas_right).with.offset(-10);
    }];
    
//    [self.fourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.threeLabel.mas_right).with.offset(10);
//        make.right.equalTo(self.contentView.mas_right).with.offset(-10);
//        make.top.equalTo(self.myImageView.mas_bottom).with.offset(5);
//        make.height.equalTo(self.threeLabel);
//        make.width.equalTo(self.threeLabel);
//    }];
    
    [self.playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.myImageView);
        make.size.mas_equalTo(CGSizeMake(50, 50));
        self.playImageView.layer.cornerRadius = 25;
        self.playImageView.layer.masksToBounds = YES;
        self.playImageView.image = [UIImage imageNamed:@"4][M]VMP0SX[CV65Z7U1XO2.jpg"];
    }];
    
    //    self.myImageView.userInteractionEnabled = YES;
    //
    //    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    //    [self.myImageView addGestureRecognizer:tap];
    //
    //    // 点几下才能触发的方法
    //    tap.numberOfTapsRequired = 1;
    //    tap.numberOfTouchesRequired = 1;
    
    
}

#pragma mark - ImageView点击手势
//// AVPlayer
//- (void)tapAction:(UITapGestureRecognizer *)tap {
//
//    AVPlayerItem *item = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:self.model.mp4_url]];
//
//    AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
//
//    self.mlayer = [AVPlayerLayer playerLayerWithPlayer:player];
//
//    self.mlayer.videoGravity = AVLayerVideoGravityResizeAspect;
//
//    self.mlayer.frame = self.myImageView.frame;
//
//    [self.contentView.layer addSublayer:self.mlayer];
//
//    self.mlayer.transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
//    
//    [player play];
//    
//    
//    
//}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
